<!--
 * @Author: 米爱 1969407518@qq.com
 * @Date: 2025-06-13 10:43:03
 * @LastEditors: 米爱 1969407518@qq.com
 * @LastEditTime: 2025-06-20 10:58:43
 * @FilePath: \CraneOperator\src\views\score.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="scoreView">
    <div class="title">
      <div>{{ $globalData.titleName }}</div>
      <div>起重机指挥实操考试自动评判系统</div>
    </div>
    <section class="scoreBox">
      <div class="scoreTitle">考试成绩</div>
      <div class="scoreContent">
        <div class="tips">
          温馨提示:考试完成，请查看考试成绩后自行离开考试机位!
        </div>
        <div class="scoreItem">
          总分：
          <div>{{ score }}</div>
          分,考试
          <div>{{ score >= 70 ? "合格" : "不合格" }}</div>
        </div>
        <div class="countDown">{{ countdown }}秒后自动跳转到登录界面</div>
      </div>
      <div>
        <button class="btn" @click="goLogin">返回登录界面</button>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  data() {
    return {
      countdown: 30, // 初始倒计时时间
      score: null,
      timer: null,
    };
  },
  methods: {
    goLogin() {
      this.$router.push({
        name: "Login",
      }); // 跳转到登录界面
    },
  },
  created() {
    this.score = this.$route.params.score;
  },
  mounted() {
    this.timer = setInterval(() => {
      if (this.countdown > 0) {
        this.countdown--; // 每秒减少1秒
      } else {
        clearInterval(this.timer); // 倒计时结束，清除定时器
        this.goLogin(); // 自动跳转到登录界面
      }
    }, 1000);
  },
  destroyed() {
    clearInterval(this.timer);
  },
};
</script>

<style scoped>
@import url(../style/score.scss);
</style>
